﻿<UserControl
    x:Class="PillBox.Client.Views.NotesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:PillBox.Client.Controls"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
	d:DataContext="{d:DesignData ../SampleData/NotesViewModelSampleData.xaml}">
    <UserControl.Resources>
		<Style x:Key="Local_NoteText" TargetType="TextBlock">
			<Setter Property="FontFamily" Value="Segoe WP N SemiBold" />
			<Setter Property="Foreground" Value="White"/>
			<Setter Property="FontSize" Value="20"/>
		</Style>
		<Style x:Key="Local_NoteMessageText" TargetType="TextBlock" BasedOn="{StaticResource Local_NoteText}">
			<Setter Property="TextWrapping" Value="Wrap" />
		</Style>
		<DataTemplate x:Key="Local_NoteFromMeDataTemplate">
			<Grid Margin="0,0,20,14">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="20"/>
					<ColumnDefinition Width="2*"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<Border 
					x:Name="Balloon"
					BorderThickness="10,0,0,0"
					BorderBrush="{Binding ColorBand}"
					Background="#FF666666"
					Grid.Row="0" 
					Padding="15,13,15,19" 
					Grid.ColumnSpan="3">
	        		<TextBlock
						x:Name="NoteMessage"
	            		Text="{Binding Message}"
						Style="{StaticResource Local_NoteMessageText}"/>
				</Border>
				<Path 
					x:Name="BalloonStem"
					Stretch="Fill"
					Data="M1,0 L0,0 L0,1 z" 
					Fill="#FF666666"
					StrokeThickness="0"
					Height="24" 
					Width="21"
					Grid.Row="1" 
					Grid.Column="1"
					VerticalAlignment="Top" 
					Margin="0,-1,0,0" 
					UseLayoutRounding="True" />
				<TextBlock 
					x:Name="NoteTime" 
					Text="{Binding Date, ConverterParameter=\{0:M/d/yy h:mm tt\}, Converter={StaticResource Converter_StringFormat}}"
					Grid.Row="1"
					Grid.Column="2"
					Margin="20,0,0,0"
					Style="{StaticResource Local_NoteText}"/>
				<TextBlock 
					x:Name="FromName" 
					Text="{Binding From}"
					Grid.Row="1"
					Grid.Column="0"
					HorizontalAlignment="Right"
					Margin="0,0,10,0"
					Style="{StaticResource Local_NoteText}"/>
			</Grid>
		</DataTemplate>
		<DataTemplate x:Key="Local_NoteFromOtherDataTemplate">
            <Grid Margin="30,0,0,14">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="2*"/>
					<ColumnDefinition Width="20"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<Border 
					x:Name="Balloon"
					BorderThickness="10,0,0,0"
					BorderBrush="{Binding ColorBand}"
					Background="{StaticResource PhoneAccentBrush}"
					Grid.Row="0" 
					Padding="15,13,15,19" 
					Grid.ColumnSpan="3">
	        		<TextBlock
						x:Name="NoteMessage"
	            		Text="{Binding Message}"
						Style="{StaticResource Local_NoteMessageText}"/>
				</Border>
				<Path 
					x:Name="BalloonStem"
					Stretch="Fill"
					Data="M0,0 L1,0 L1,1 z" 
					Fill="{StaticResource PhoneAccentBrush}"
					StrokeThickness="0"
					Height="24" 
					Width="21"
					Grid.Row="1" 
					Grid.Column="1"
					VerticalAlignment="Top" 
					Margin="0,-1,0,0" 
					UseLayoutRounding="True" />
				<TextBlock 
					x:Name="FromName" 
					Text="{Binding From}"
					Grid.Row="1"
					Grid.Column="2"
					Margin="10,0,0,0"
					Style="{StaticResource Local_NoteText}"/>
				<TextBlock 
					x:Name="NoteTime" 
					Text="{Binding Date, ConverterParameter=\{0:M/d/yy h:mm tt\}, Converter={StaticResource Converter_StringFormat}}"
					Grid.Row="1"
					Grid.Column="0"
					HorizontalAlignment="Right"
					Margin="0,0,20,0"
					Style="{StaticResource Local_NoteText}"/>
			</Grid>
		</DataTemplate>
        <controls:NoteTemplateSelector
            x:Key="Local_NoteTemplateSelector"
            NoteFromMeDataTemplate="{StaticResource Local_NoteFromMeDataTemplate}"
            NoteFromOtherDataTemplate="{StaticResource Local_NoteFromOtherDataTemplate}"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <ScrollViewer
            BorderThickness="0"
            Margin="0,0,20,0"
            VerticalScrollBarVisibility="Hidden">
            <ItemsControl
                ItemsSource="{Binding Notes}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <controls:ContentControl2
                            Content="{Binding}"
                            TemplateSelector="{StaticResource Local_NoteTemplateSelector}"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>